package com.zz.ecommerce.reportStat;

import com.zz.ecommerce.utils.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wangyanning on 2015/8/19.
 */
@Controller
@RequestMapping("/reportStat")
public class ReportStatController {

    @Autowired
    private StsAnalysisService stsAnalysisService;

    @Autowired
    private ReportStatDao reportStatDao;

    @RequestMapping("/init")
    public String init() {
        return "/reportStat/index";
    }


    @RequestMapping("/totalIEOrder")
    @ResponseBody
    public Map<String, Object> totalOrder(ModelMap modelMap, HttpSession session) {
        String orgId = SessionUtil.getOrganizationId(session);
        List<Map<String, String>> importOrderList = reportStatDao.totalImportOrder(orgId);
        List<Map<String, String>> exportOrderList = reportStatDao.totalExportOrder(orgId);

        Map<String, Object> result = new HashMap<String, Object>();
        result.put("import", importOrderList);
        result.put("export", exportOrderList);
        return result;
    }

    /**
     * 经营实体统计分析数据-备案量分布图
     */
    @RequestMapping(value = "/qryEntStsChartE", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, List<StsAnalysisBean>> qryEntStsChartE() {
        return stsAnalysisService.qryEntStsChartE();
    }


    /**
     * 经营实体统计分析数据-企业类型数量统计图
     */
    @RequestMapping(value = "/qryEntStsChartB", method = RequestMethod.POST)
    @ResponseBody
    public List<StsAnalysisBean> qryEntStsChartB() {
        return stsAnalysisService.qryEntStsChartB();
    }


    /**
     * 经营实体统计分析数据-各直属局备案量统计图
     */
    @RequestMapping(value = "/qryEntStsChartC", method = RequestMethod.POST)
    @ResponseBody
    public List<StsAnalysisBean> qryEntStsChartC() {
        return stsAnalysisService.qryEntStsChartC();
    }


    /**
     * 经营实体统计分析数据-近一年内备案经营主体趋势图
     */
    @RequestMapping(value = "/qryEntStsChartD", method = RequestMethod.POST)
    @ResponseBody
    public List<StsAnalysisBean> qryEntStsChartD() {
        return stsAnalysisService.qryEntStsChartD();
    }

}
